﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ICTBilling;

/// <summary>
/// Summary description for tbCenterEquipment
/// </summary>
public partial class tbCenterEquipment : IValidate
{
    public List<ExceptionHandler> Validate(ChangeAction changeAction)
    {
        List<ExceptionHandler> ExecutionCollection = new List<ExceptionHandler>();
        try
        {
            if (changeAction == ChangeAction.Insert ||
                changeAction == ChangeAction.Update)
            {
                if (changeAction == ChangeAction.Update && this.FkCenterID == null)
                    ExecutionCollection.Add(new ExceptionHandler("PkCenterID", "شناسه مرکز", ICTBilling.ExceptionType.NullArgumant));

                if (changeAction == ChangeAction.Update && this.FkEquipmentID == null)
                    ExecutionCollection.Add(new ExceptionHandler("PkCenterID", "شناسه تجهیزات", ICTBilling.ExceptionType.NullArgumant));

                if (this.Count == null)
                    ExecutionCollection.Add(new ExceptionHandler("Count", "تعداد", ICTBilling.ExceptionType.NullArgumant));
                else if (this.Count > 255 || this.Count < 1)
                    ExecutionCollection.Add(new ExceptionHandler("Count", "تعداد", ICTBilling.ExceptionType.ShortFormat));
                else
                {
                    try
                    {
                        byte.Parse(this.Count.ToString());
                    }
                    catch (FormatException)
                    {
                        ExecutionCollection.Add(new ExceptionHandler("Count", "تعداد", ICTBilling.ExceptionType.ShortFormat));
                    }
                }
            }
        }
        catch (Exception _Exception)
        {
            ExecutionCollection.Add(new ExceptionHandler(_Exception));
        }
        return ExecutionCollection;
    }
}